package cn.com.sbell.vss.ems.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.com.sbell.vss.BaseDao;
import cn.com.sbell.vss.ems.dao.IUserRoleDao;
import cn.com.sbell.vss.ems.entity.UserRole;

public class UserRoleDaoImpl extends BaseDao implements IUserRoleDao {

	public String insert(UserRole userRole) {
		userRole.setId(generateRandomGUID());
		this.getSqlMapClientTemplate().insert("insertUserRole", userRole);
		return userRole.getId();
	}

	public void update(UserRole userRole) {
		this.getSqlMapClientTemplate().update("updateUserRole", userRole);
	}

	public void delete(String id) {
		this.getSqlMapClientTemplate().delete("deleteUserRole", id);
	}

	public void delete(Map param) {
		this.getSqlMapClientTemplate().delete("deleteUserRoles", param);
	}

	public List find(Map param) {
		return getSqlMapClientTemplate().queryForList("findUserRole", param);
	}

	public List findAreaIdByUserRoleId(String domainId, String userId,
			List roleIds) {
		Map param = new HashMap();
		param.put("domainId", domainId);
		param.put("userId", userId);
		param.put("roleIds", roleIds);
		return this.getSqlMapClientTemplate().queryForList(
				"findAreaIdByUserRoleId", param);
	}

}
